<template>
  <view class="mine-container" :style="{height: `${windowHeight}px`}">
    <!-- 顶部标题栏 -->
    

    <!-- 用户信息卡片 -->
    <view class="user-card">
      <view class="avatar-wrapper">
        <view v-if="!avatar" class="cu-avatar xl round bg-white">
          <view class="iconfont icon-people text-gray icon"></view>
        </view>
        <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
        </image>
      </view>
      <view class="user-info">
        <view class="user-name">admin</view>
        <view class="user-role">普通用户</view>
      </view>
      <view class="profile-btn" @click="handleToInfo">
        <text>个人信息</text>
        <text class="btn-arrow">›</text>
      </view>
    </view>

    <!-- 功能菜单 -->
    <view class="menu-card">
      <view class="menu-item" @click="handleToEditInfo">
        <view class="menu-icon edit-icon">
          <view class="iconfont icon-user"></view>
        </view>
        <view class="menu-text">
          <view class="menu-title">编辑资料</view>
          <view class="menu-desc">更新您的个人信息</view>
        </view>
        <view class="menu-arrow">›</view>
      </view>
      
      <view class="menu-item" @click="handleToSetting">
        <view class="menu-icon settings-icon">
          <view class="iconfont icon-setting"></view>
        </view>
        <view class="menu-text">
          <view class="menu-title">应用设置</view>
          <view class="menu-desc">自定义您的应用体验</view>
        </view>
        <view class="menu-arrow">›</view>
      </view>
    </view>

   
  </view>
</template>

<script>
  export default {
    data() {
      return {
        name: this.$store.state.user.name
      }
    },
    computed: {
      avatar() {
        return this.$store.state.user.avatar
      },
      windowHeight() {
        return uni.getSystemInfoSync().windowHeight - 50
      }
    },
    methods: {
      handleToInfo() {
        this.$tab.navigateTo('/pages/mine/info/index')
      },
      handleToEditInfo() {
        this.$tab.navigateTo('/pages/mine/info/edit')
      },
      handleToSetting() {
        this.$tab.navigateTo('/pages/mine/setting/index')
      },
      handleToLogin() {
        this.$tab.reLaunch('/pages/login')
      },
      handleToAvatar() {
        this.$tab.navigateTo('/pages/mine/avatar/index')
      },
      handleHelp() {
        this.$tab.navigateTo('/pages/mine/help/index')
      },
      handleAbout() {
        this.$tab.navigateTo('/pages/mine/about/index')
      },
      handleJiaoLiuQun() {
        this.$modal.showToast('QQ群：①133713780(满)、②146013835(满)、③189091635')
      },
      handleBuilding() {
        this.$modal.showToast('模块建设中~')
      }
    }
  }
</script>

<style lang="scss" scoped>
  page {
    background-color: #f5f7fa;
  }

  .mine-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: #f5f7fa;
  }

  /* 顶部标题栏 */
  .nav-header {
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
  }

  .page-title {
    font-size: 18px;
    font-weight: 500;
    color: #333;
  }

  /* 用户信息卡片 */
  .user-card {
    margin: 15px;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    position: relative;
  }

  .avatar-wrapper {
    margin-right: 15px;
  }

  .cu-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
  }

  .user-info {
    flex: 1;
  }

  .user-name {
    font-size: 18px;
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
  }

  .user-role {
    font-size: 14px;
    color: #999;
  }

  .profile-btn {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background-color: rgba(76, 132, 255, 0.1);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    color: #4c84ff;
  }

  .btn-arrow {
    margin-left: 3px;
  }

  /* 功能菜单 */
  .menu-card {
    margin: 0 15px;
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
  }

  .menu-item {
    padding: 20px;
    display: flex;
    align-items: center;
    position: relative;
    
    &:not(:last-child) {
      border-bottom: 1px solid #f5f7fa;
    }
  }

  .menu-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    
    .iconfont {
      color: white;
      font-size: 20px;
    }
  }
  
  .edit-icon {
    background-color: #4c84ff;
  }
  
  .settings-icon {
    background-color: #7468fe;
  }

  .menu-text {
    flex: 1;
  }

  .menu-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
  }

  .menu-desc {
    font-size: 13px;
    color: #999;
  }

  .menu-arrow {
    font-size: 18px;
    color: #ccc;
  }

  /* 底部选项卡 */
  .tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: white;
    display: flex;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.05);
  }

  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    
    &.active {
      color: #4c84ff;
    }
  }

  .tab-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 3px;
  }

  .tab-text {
    font-size: 12px;
  }

  /* 通用样式 */
  .text-gray {
    color: #999;
  }

  .round {
    border-radius: 50%;
  }

  .bg-white {
    background-color: white;
  }

  .xl {
    width: 70px;
    height: 70px;
  }

  .icon {
    font-size: 35px;
  }
</style>
